package com.swm.model;

import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "Project")
public class Project {
	
	public Project(){	
	}
	public Project( String name ){
		this.name = name;
	}
	private String key;
	private String name;
	
	private List<User> 		userList;
	private List<Testcase> 	testcaseList;
	private ProjectInfo		projectInfo;

	
	public List<User> getUserList() {
		return userList;
	}
	public List<Testcase> getTestcaseList() {
		return testcaseList;
	}
	public boolean addUser( User user ){		
		return userList.add( user );
	}
	public boolean addTestcase( Testcase testcase ){
		return testcaseList.add( testcase );		
	}
	
	public boolean delTestcase( Testcase testcase ){
		return testcaseList.remove( testcase );
	}
	public ProjectInfo getProjectInfo() {
		return projectInfo;
	}
	
	public boolean isBeingUser( User user ){
		for( User users : userList ){
			if ( users.isEqual( user ))
				return true;
		}
		return false;
	}
	
	public boolean isBeingUser( String userID ){
		for( User user : userList ){
			if ( user.isEqual( userID )){
				System.out.println( "[USERLIST] "+ user.getId());
				return true;
			}
		}
		return false;
	}
	

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public boolean isEqual( String projectID ){
		if( name.equals( projectID ))
			return true;
		return false;
	}
	
	public Testcase getTestcase(String testcaseID) {		
		for( Testcase testcase : testcaseList ){
			if ( testcase.getTestcaseName().equals( testcaseID )){				
				return testcase;
			}
		}
		return null;
	}
	public boolean modifyTestcase(Testcase request ) {
		for( Testcase testcase : testcaseList ){
			if ( testcase.getTestcaseName().equals( testcase.getTestcaseName() )){				
				testcase.setContents( request.getContents() );
			}
		}
		return false;
	}
}
